<%@ codepage=65001%>
<%if session("login")<>"ok" then%>
<script language="JavaScript">

//alert("")
location.href="login.asp"
</script>
<%
response.End
end if%>
<%
Session.CodePage=65001
Response.Charset="utf-8"
set conn=server.createobject("adodb.connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& Server.MapPath("data.mdb")
'connstr = "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("test.mdb")
conn.open connstr
'查询一级片区
set rs= server.createobject("adodb.recordset")
sqlstr = "select * from saleAreaLv1"
rs.open sqlstr,conn,1,1
strSaleAreaTree = "{text: '销售片区',expanded:true,lnglat: '10444800,3514368',children: ["
if rs.RecordCount <> 0 then
	Do while not rs.eof or rs.bof
		strSaleAreaTree = strSaleAreaTree & "{text:'"&rs("saleAreaName")&"',soleId:'"&rs("id")&"',salerId:'"&rs("salerId")&"',areaColor:'"&rs("areaColor")&"'"
		'查询二级片区
		set rs1= server.createobject("adodb.recordset")
		sqlstr1 = "select * from saleAreaLv2 where saleAreaLv1 = '"&rs("id")&"'"
		rs1.open sqlstr1,conn,1,1
		if rs1.RecordCount <> 0 then
			strSaleAreaTree = strSaleAreaTree &",leaf:false"
			strSaleAreaTree = strSaleAreaTree &",children:["
			Do while not rs1.eof or rs1.bof
				strSaleAreaTree = strSaleAreaTree &"{text:'"&rs1("saleAreaName")&"',leaf:true,soleId:'"&rs1("id")&"',salerId:'"&rs1("salerId")&"',areaColor:'"&rs1("areaColor")&"'},"
				rs1.movenext
			loop
			strSaleAreaTree = left(strSaleAreaTree,len(strSaleAreaTree)-1)
			strSaleAreaTree = strSaleAreaTree &"]"
		else
			strSaleAreaTree = strSaleAreaTree &",leaf:true"
		end if
		strSaleAreaTree = strSaleAreaTree &"},"
		rs.movenext
	loop
	'去掉最后一个逗号
	strSaleAreaTree = left(strSaleAreaTree,len(strSaleAreaTree)-1)
else
	strSaleAreaTree = strSaleAreaTree & "{text:'无',soleId:'',salerId:'',areaColor:'',leaf:true}"
end if
strSaleAreaTree = strSaleAreaTree &"]}"
conn.close
'response.Write(strSaleAreaTree)
%>
<html xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>网点查询地图系统</title>
<link rel="stylesheet" type="text/css" href="ext/ext-3.3.1/resources/css/ext-all.css"/>
<script type="text/javascript" src="ext/ext-3.3.1/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext/ext-3.3.1/ext-all.js"></script>
<script type="text/javascript" src="citys/tree.js"></script>
<script type="text/javascript" src="citys/tree_checked.js"></script>
<script language="javascript" src="http://api.51ditu.com/js/maps.js"></script>
<script language="javascript" src="http://api.51ditu.com/js/ezmarker.js"></script>
<script type="text/javascript" src="http://api.51ditu.com/js/bus.js"></script>
<script language="javascript" src="http://api.51ditu.com/js/navigate.js"></script>
<style type="text/css">v\:*{behavior:url(#default#VML);}</style>
<style type="text/css">
.zhandian01 {background-image: url("icons/bus/zhandian01.gif");background-position: left top;background-repeat: no-repeat;display: inline;float: left;height: 28px;margin: 0 auto;}

.zhandian02 {background-image: url("icons/bus/zhandian02.gif");background-position: center top;background-repeat: repeat-x;border-right: 1px solid #666666;display: inline;float: left;line-height: 21px;margin: 0 5px 0 14px;padding-right: 4px;
}
</style>
<script type="text/javascript">
Ext.BLANK_IMAGE_URL = 'ext/ext-3.3.1/resources/images/default/s.gif';
var strSaleAreaTree = [<%=strSaleAreaTree%>];	//片区树
var maps;
var regionPolygonArry = [];	//叠加的行政区划
//var areaColor = "";
var pageSize = 50;	//每页显示的最大值
var user_p="<%=session("p")%>"
//var treeHeightInitialize = 0;	//地区导航初始高度

var markerChange = [];

//------客户信息查询的全局变量开始------
var pointsOffice = [];
var pointsHouse = [];
var ids = [];
var customerName = [];
var customerOfficeAdress = [];
var customerStoreHouse = [];
var province = [];
var kehuxiaqu = [];
var kehufuzeren = [];
var kehufuzerenTel = [];
var beizhu = [];
//------客户信息查询的全局变量结束------

//------网点信息查询的全局变量开始------
var pointsAddress = [];
var idsWandDian = [];
var wangdianName = [];
var wangdianAddress = [];
var provinceWangDian = [];
var saleAreaId = [];
var wangdianAreaOwen = [];
var wangdianfuzeren = [];
var wdfzrTel = [];
var wangdianyewuren = [];
var wdywrTel = [];
var saleId = [];
var wangdianPhoto = [];
var wangdianOwen = [];
var beizhu = [];
//------网点信息查询的全局变量结束------

//------采集网点信息查询的全局变量开始------
var caiJiPoints = [];
var caiJiIDS = [];
var caiJiWangDianName = [];
var caiJiWangDianNumber = [];
var caiJiLandmarksName = [];
var caiJiPositionAddress = [];
var caiJiWangdianPhone = [];
//------采集网点信息查询的全局变量结束----

Ext.onReady(function(){
	maps = new LTMaps( "myMap" );
	maps.centerAndZoom(new LTPoint(10444800,3514368),13);	//定位全国
	var standMapControl = new LTStandMapControl();
	maps.addControl(standMapControl);
	maps.handleMouseScroll(true);//启用鼠标滚轮功能支持,参数true代表使用鼠标指向点位置不变模式
	control=new LTPolyLineControl();//增加测距控件
	control.setTips("双击结束");//改变操作提示文字内容
	LTEvent.bind(maps,"dblclick",control,control.endDraw);//在双击地图的时候调用结束操作
	maps.addControl(control);
	controlm=new LTPolygonControl();
	controlm.setTips("双击结束");//改变操作提示文字内容
	LTEvent.bind(maps,"dblclick",controlm,controlm.endDraw);//在双击地图的时候调用结束操作
	maps.addControl(controlm);
	control.setVisible(false);
	controlm.setVisible(false);
	
	// 权限判断start
	var loadTree = [];
	loadTree.push(formTree)
	if (userTypeTF(user_p,4)){
		loadTree.push(formSaleAreaTree);
	}
	if (userTypeTF(user_p,1)){
		loadTree.push(formWangDianSearch);
	}
	if (userTypeTF(user_p,2)){
		loadTree.push(formCustomerSearch);
	}
	loadTree.push(formCaiJiSearch);
	loadTree.push(formUploadPositionSearch);
	loadTree.push(formTracksSearch);
	if (userTypeTF(user_p,3)){
		loadTree.push(formRoadSearch);
	}
	loadTree.push(grid)
	// 权限判断end

    // 布局开始
    var viewport = new Ext.Viewport({
        layout:'border',
        items:[{
            region: 'north',
            contentEl: 'north-div',
            height: 55,
            bodyStyle: 'background-color:#BBCCEE;'
        },{
			region:'center',
			xtype:'panel',
			title:'地图',
			tbar:[
				{text:'放大',handler:function(){maps.zoomIn();}},
				{text:'缩小',handler:function(){maps.zoomOut()}},
				{text:'测距',handler:function(){control.btnClick();}},
				{text:'测面',handler:function(){controlm.btnClick();}},
				{text:'打印',handler:function(){printMap(maps)}},
				{text:'清空地图',handler:function(){maps.clearOverLays();}}
			],
			//bbar:[{text:'全部网点显示',handler:function(){maps.clearOverLays();
//				customerJsonStore.removeAll();
//				customerJsonStore.load({params: {start:0,limit:pageSize,citycode:"",type:"init"},callback:function(r,options,success){if(ds.getCount() == 0){Ext.MessageBox.alert('提示', "搜索无结果");}}});
//					//加载JSON数据给地图对象
//					ds.addListener('load', function(st, rds, opts){
//						if(maps)
//						{
//							maps.clearOverLays();
//						}
//					});
//				}
//			}],
			tools:[{id:""}],
			listeners:{"bodyresize":function(){if(typeof(maps)=="object"){maps.resizeMapDiv();}}},//监控地图大小改变后,地图自适应
			contentEl:'myMap'
		}
		,{
            region: 'south',
            contentEl: 'south-div',
            height: 20,
            bodyStyle: 'background-color:#BBCCEE;'
        }
		,{
            //region: 'east',
			region: 'west',
			collapsible:true,
            split: true,
            border: true,
            //layout: 'border',
			layout: 'accordion',
			layoutConfig:{
				titleCollapse:true,
				animate:true,
				activeOnTop:false
			},
			width:300,
            items: loadTree
        }
		]
    });
    // 布局结束
	//地图打印
	function printMap(maps)
	{
		var html = "<!DOCTYPE HTML\">\n";
		html += (document.all)?"<html xmlns:v=\"urn:schemeas-microsoft-com:vml\">":"<html>";
		html += "\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\n<title>Print Maps<\/title>\n";
		html += "<style type=\"text\/css\">\nbody {margin: 0px;}\n";
		html += (document.all)?"v\\:*{ Behavior:url(#default#VML);}":"";
		html += "\n</style>\n";
		html += "<\/head>\n";
		html += "<body><right>\n";
		html += maps.getMapContent(0);//改变"0"这个参数，可以将地图之中的标注也打印到地图，具体请参照类参考文档之中的getMapContent说明
		html += "\n<\/right><\/body>\n<\/html>";
		var win = window.open("about:blank","win","menubar=1,width="+(maps.container.offsetWidth)+",height="+(maps.container.offsetHeight-20));
		win.document.writeln(html);
		win.moveTo(0,0);
		win.print();
		win.document.close();	
		win.close();
	}
	//Ext.fly(Ext.get('treeCitysSearch')).setHeight(parseInt(document.body.clientHeight)-122-108,true)
	treeCitysSearch.setHeight(parseInt(document.body.clientHeight)-122-117);
});

Ext.EventManager.onWindowResize(function(width,height){//改变窗口的时候会提示出窗口的宽高
	treeCitysSearch.setHeight(parseInt(height)-122-117);
});

//-----------------------------------------地区导航开始-----------------------------------------------
//加载城市列表
var treeCitysSearch = new Ext.tree.TreePanel({
	loader: new Ext.tree.TreeLoader(),
	//title: '地区导航',
	id:"treeCitysSearch",
	el:'treeCitysSearch',
	split: true,
	//border: true,
	rootVisible:false,
	autoScroll: true,
	//bodyStyle : 'overflow-x:visible; overflow-y:visible',
	autoHeight:false,
	width: 310
});

var rootCitysSearch = new Ext.tree.AsyncTreeNode({
	text:'root',
	expanded :true,
	width:"100%",
	//height:"1000px",
	children:citys_tree_obj	//不带复选框的城市列表
});
treeCitysSearch.setRootNode(rootCitysSearch);
treeCitysSearch.expand();

treeCitysSearch.on("click", function(node){
	//alert(node.leaf);
	
	if(maps)
	{
		maps.clearOverLays();
	}
	
	var nodeCity = [];
	nodeCity.push(node.text);
	try{
		//获取所有父节点
		var pNode = node.parentNode;
		for(;pNode.id !="root";pNode = pNode.parentNode ){
			if (treeCitysSearch.getChecked(id, node.parentNode) == "")
			{
				if(pNode.text!="root"&&pNode.text!="全国")
				{
					nodeCity.push(pNode.text);
				}
			}
		}
	}catch(e){}
	//alert(nodeCity.reverse().join(""));
	grid.getBottomToolbar().bind(wangDianJsonStore);//重新绑定分页
	grid.reconfigure(wangDianJsonStore,wangDianList);	//更换显示的数据
	
	searchWayWangDianValue = nodeCity.reverse().join("");
	
	//alert(searchWayWangDianValue);
	
	xtype = 4;	//类型为4，表示按树节点的行政区划查询
	
	wangDianJsonStore.removeAll();
	maps.clearOverLays();
	wangDianJsonStore.on('beforeload',function(){
		Ext.apply(
		this.baseParams,
		{
			//provinceWangDian:Ext.getCmp("provinceWangDian").getValue(),
			xtype:xtype,
			searchWayWangDianValue:searchWayWangDianValue,
			customerKeyWordWangDian:Ext.getCmp("customerKeyWordWangDian").getValue()
		});
	});
	wangDianJsonStore.load({
		params: {
			start:0,
			limit:pageSize,
			//provinceWangDian:Ext.getCmp("provinceWangDian").getValue(),
			xtype:xtype,
			searchWayWangDianValue:searchWayWangDianValue,
			customerKeyWordWangDian:Ext.getCmp("customerKeyWordWangDian").getValue()
		},callback:function(r,options,success){
			if(wangDianJsonStore.getCount() == 0){
				//将地图移动到所点击的行政区划
				placeList=LTPlaceList.getDefault();
				var place=placeList.searchPlace(node.text,1)[0];
				if(place)
				{
					//获取该地名的坐标
					var point=place.getPoint();
					//alert(point.getLongitude()+"||"+point.getLatitude());
					var zoom = 5;
					if(point)
					{
						if(place.getName() == "全国")
						{
							zoom = 13;
						}
						if(place.getName() != "全国" && node.leaf != true)
						{
							zoom = 8;
						}
						//有些地名可能没有坐标信息
						maps.centerAndZoom(point,zoom);
					}
				}
				Ext.MessageBox.alert('提示', "搜索无结果");
			}else{
				grid.expand();
			}
		}
	});
});
var formTree = new Ext.form.FormPanel({
	defaultType: 'textfield',
	labelAlign: 'right',
	title: '地区导航',
	labelWidth: 60,
	frame:true,
	width: 310,
	//height:300,
	autoHeight:false,
	buttonAlign: 'center',
	//bodyStyle : 'overflow-x:visible; overflow-y:visible',
	//autoHeight:150,
	//region: 'north',
	//reader: reader,
	items: treeCitysSearch
});
//-----------------------------------------地区导航结束--------------------------------------------------

//-----------------------------------------销售片区导航开始-----------------------------------------------
//加载城市列表
var treeSaleAreaSearch = new Ext.tree.TreePanel({
	loader: new Ext.tree.TreeLoader(),
	//title: '地区导航',
	el:'treeSaleAreaSearchDiv',
	split: true,
	//border: true,
	rootVisible:false,
	autoScroll: true
});

var rootSaleAreaSearch = new Ext.tree.AsyncTreeNode({
	text:'root',
	//expanded :true,
	width:"100%",
	//height:"1000px",
	children:strSaleAreaTree	//不带复选框的城市列表
});
treeSaleAreaSearch.setRootNode(rootSaleAreaSearch);
treeSaleAreaSearch.expand();
/*var path = rootCitysSearch.getPath('id');
alert(path);
//treeCitysSearch.getRootNode().reload();	//刷新树
treeCitysSearch.expandPath(path,'id');
treeCitysSearch.expand();
//treeCitysSearch.render();*/

treeSaleAreaSearch.on("click", function(node){
	//alert(node.text);
	if(maps)
	{
		maps.clearOverLays();
	}
	
	
	var nodeCity = [];
	nodeCity.push(node.text);
	/*try{
		//获取所有父节点
		var pNode = node.parentNode;
		for(;pNode.id !="root";pNode = pNode.parentNode ){
			if (treeCitysSearch.getChecked(id, node.parentNode) == "")
			{
				if(pNode.text!="root"&&pNode.text!="销售片区")
				{
					nodeCity.push(pNode.text);
				}
			}
		}
	}catch(e){}*/
	//alert(nodeCity.reverse().join(""));
	grid.getBottomToolbar().bind(wangDianJsonStore);//重新绑定分页
	grid.reconfigure(wangDianJsonStore,wangDianList);	//更换显示的数据
	
	searchWayWangDianValue = nodeCity.reverse().join("");
	
	//alert(searchWayWangDianValue);
	
	xtype = 5;	//类型为5，表示查询当前片区内的网点信息
	
	wangDianJsonStore.removeAll();
	//maps.clearOverLays();
	wangDianJsonStore.on('beforeload',function(){
		Ext.apply(
		this.baseParams,
		{
			//provinceWangDian:Ext.getCmp("provinceWangDian").getValue(),
			xtype:xtype,
			searchWayWangDianValue:searchWayWangDianValue,
			customerKeyWordWangDian:Ext.getCmp("customerKeyWordWangDian").getValue()
		});
	});
	wangDianJsonStore.load({
		params: {
			start:0,
			limit:pageSize,
			//provinceWangDian:Ext.getCmp("provinceWangDian").getValue(),
			xtype:xtype,
			searchWayWangDianValue:searchWayWangDianValue,
			customerKeyWordWangDian:Ext.getCmp("customerKeyWordWangDian").getValue()
		},callback:function(r,options,success){
			if(wangDianJsonStore.getCount() == 0){
				//Ext.MessageBox.alert('提示', "搜索无结果");
			}else{
				grid.expand();
			}
		}
	});
	
	//alert(node.attributes.salerId);
	var salerId = node.attributes.salerId;
	if(salerId == "" || typeof salerId == "undefined")
	{
		return;
	}
	var areaColor = node.attributes.areaColor;
	if(salerId.indexOf(",") != -1)
	{
		var salerIdArr = salerId.split(",");
		
		//计算最佳地图显示的比例尺
		var salerIdBestMap = [];
		var placeList=LTPlaceList.getDefault();
		
		//画行政区划
		for(var i=0;i<salerIdArr.length;i++)
		{
			var place=placeList.searchPlace(salerIdArr[i],1)[0];
			if(place)
			{
				//获取该地名的坐标
				var point=place.getPoint();
				if(point)
				{
					salerIdBestMap.push(point);
				}
			}
			drawRegion(salerIdArr[i],areaColor);
			//break;
		}
		maps.getBestMap(salerIdBestMap);
	}
	else
	{
		var regionPoly = new LTRegionControl(drawRegion);
		regionPoly.setRegion(salerId);
		regionPoly.getRegion();
	}
});
var formSaleAreaTree = new Ext.form.FormPanel({
	defaultType: 'textfield',
	labelAlign: 'right',
	title: '销售片区导航',
	labelWidth: 60,
	frame:true,
	width: 220,
	buttonAlign: 'center',
	//autoHeight:150,
	//region: 'north',
	//reader: reader,
	items: treeSaleAreaSearch
});

function drawRegion(name,color)
{
	var regionPoly = new LTRegionControl(function(obj){
		var pointsJSON = obj.getPoints()[0];
		if(obj.getPoints())
		{
			//obj.style.zIndex=110;
			//生成折线的点数组
			var points = new Array();
			for(var i=0;i<pointsJSON.length;i++)
			{
				points.push(new LTPoint(pointsJSON[i].getLongitude(),pointsJSON[i].getLatitude()));
				//alert(points[i].getLongitude()+"||"+points[i].getLatitude());
			}
			var option = new LTPolygonOptions();
			option.points = points;
			var polygon = new LTPolygonOverlay(option);
			maps.addOverLay(polygon);
			
			/*//设置边框颜色
			maps.setLineColor();
			//设置边框宽度
			maps.setLineStroke();
			//设置边框样式
			maps.setLineStyle();
			//设置透明度
			maps.setOpacity();
			//设置填充色*/
			polygon.setFillColor("#"+color);
			
			regionPolygonArry.push(polygon);
			
			polygon.getObject().style.zIndex=110;
		}
	});
	regionPoly.setRegion(name);
	regionPoly.getRegion();
}

//function drawRegion(obj)
//{
//	//regionPoly.drawPolygon(maps);	//行政区划叠加画面的方法
//	var pointsJSON = obj.getPoints()[0];
//	if(obj.getPoints())
//	{
//		//生成折线的点数组
//		var points = new Array();
//		for(var i=0;i<pointsJSON.length;i++)
//		{
//			points.push(new LTPoint(pointsJSON[i].getLongitude(),pointsJSON[i].getLatitude())); 
//			//alert(points[i].getLongitude()+"||"+points[i].getLatitude());
//		}
//		var option = new LTPolygonOptions(); 
//		option.points = points; 
//		var polygon = new LTPolygonOverlay(option);
//		maps.addOverLay(polygon);
//		
//		/*//设置边框颜色 
//		maps.setLineColor();
//		//设置边框宽度
//		maps.setLineStroke();
//		//设置边框样式
//		maps.setLineStyle();
//		//设置透明度
//		maps.setOpacity();
//		//设置填充色*/
//		polygon.setFillColor("red");
//		regionPolygonArry.push(polygon);
//	}
//}
//-----------------------------------------销售片区导航结束-----------------------------------------------

//-----------------------------------------客户信息查询开始-----------------------------------------------
//客户信息查询
var formCustomerSearch = new Ext.form.FormPanel({
	id: 'formCustomerSearchID',
	name: 'formCustomerSearchID',
	title: '客户信息查询',
	autoHeight: true,
	frame: true,
	layout: "form", // 整个大的表单是form布局
	labelWidth: 60,
	labelAlign: "right",
	items: [
	{ //行1
		layout: "column", // 从左往右的布局
		items: [
			{
				columnWidth: .7, // 该列有整行中所占百分比
				layout: "form", // 从上往下的布局
				//labelWidth: 120,
				items: [{xtype: 'textfield',name:'provinceSearch',id:'provinceSearch',fieldLabel: '选择城市',width: 130,value:""}]
			},
			{
				columnWidth: .3,
				layout: "form",
				//labelWidth: 120,
				items: [{xtype: 'button',handler:function(){citysWin(cityOptionsSearch);}, name: 'cityAddress',id:"cityAddress",text:'选择',width: 60,height:22}]
			}
		]
	},
	{
		columnWidth : .50,
		fieldLabel: '类别',
		xtype : "panel",
		//bodyStyle : "background-color:block",
		frame:true,
		layout : "column",// 也可以是table,实现多列布局
		//fieldLabel : '爱好',
		isFormField : true,// 非常重要,否则panel默认不显示fieldLabel
		items : [
			{
				xtype : "checkbox",
				columnWidth : .33,
				boxLabel : "办公地址",
				name : "customerOfficeAdressSearch",
				id : "customerOfficeAdressSearch",
				inputValue : 1
			},{
				xtype : "checkbox",
				columnWidth : .34,//采集者退散
				// anchor : '97%',
				boxLabel : "仓库地址",
				name : "customerStoreHouseSearch",
				id : "customerStoreHouseSearch",
				inputValue : 2
			}
		]
	},
	//类别选取择强束
	{
		xtype: 'textfield',
		name:'customerKeyWord',
		id:'customerKeyWord',
		fieldLabel: '关键词',
		anchor: '90%'
	}],
	buttons: [{
		text: '查询',
		handler:function(){
			//alert(formCustomerSearch.form.findField("customerOfficeAdressSearch").getValue());
			//alert(Ext.getCmp("customerOfficeAdressSearch").getValue());
			grid.getBottomToolbar().bind(customerJsonStore);//重新绑定分页
			grid.reconfigure(customerJsonStore,customerList);	//更换显示的数据
			customerJsonStore.removeAll();
			maps.clearOverLays();
			grid.expand();
			customerJsonStore.on('beforeload',function(){
				Ext.apply(
				this.baseParams,
				{
					provinceSearch:Ext.getCmp("provinceSearch").getValue(),
					customerOfficeAdressSearch:Ext.getCmp("customerOfficeAdressSearch").getValue(),
					customerStoreHouseSearch:Ext.getCmp("customerStoreHouseSearch").getValue(),
					customerKeyWord:Ext.getCmp("customerKeyWord").getValue()
				});
			});
			customerJsonStore.load({
				params: {
					start:0,
					limit:pageSize,
					provinceSearch:Ext.getCmp("provinceSearch").getValue(),
					customerOfficeAdressSearch:Ext.getCmp("customerOfficeAdressSearch").getValue(),
					customerStoreHouseSearch:Ext.getCmp("customerStoreHouseSearch").getValue(),
					customerKeyWord:Ext.getCmp("customerKeyWord").getValue()
				}
				,callback:function(r,options,success){if(customerJsonStore.getCount() == 0){Ext.MessageBox.alert('提示', "搜索无结果");}}
			})
		}
	}]
});

//给客户的所属城市赋值
function cityOptionsSearch(cityArr)
{
	Ext.getDom("provinceSearch").value = "";
	for(var i=cityArr.length-1;i>=0;i--)
	{
		if(cityArr[i]!="root"&&cityArr[i]!="全国")
		{
			Ext.getDom("provinceSearch").value += cityArr[i];//设定经度
		}
	}
}

//客户信息查询列表
var customerList = new Ext.grid.ColumnModel([
	{header:'编号',dataIndex:'id'},
	{header:'客户名称',dataIndex:'customerName'},
	{header:'所属城市',dataIndex:'province'}
	//{header:'描述',dataIndex:'detail'}
]);

var customerJsonStore = new Ext.data.JsonStore({
	url: "json_customerInfoSearch_client.asp",
	root: "root",
	totalProperty: 'mytotal',
	//remoteSort:true,
	baseParams:{start:0,limit:pageSize},
	idProperty: "id",
	//fields: ["id", "name", "info","icon","lag","lat","file1"]
	fields: ["id","customerName","customerOfficeAdress","customerOfficeAdressLng","customerOfficeAdressLat","customerStoreHouse","customerStoreHouseLng","customerStoreHouseLat","province","city","district","kehuxiaqu","kehufuzeren","kehufuzerenTel","beizhu"]
});

var grid = new Ext.grid.GridPanel({
	store:customerJsonStore,
	cm: customerList,
	loadMask: true,
	closable: true,
	frame:true,
	title: '信息列表',
	bbar: new Ext.PagingToolbar({
		pageSize:pageSize,
		store:customerJsonStore,
		displayInfo:true,
		displayMsg:'显示第{0}条到{1}条记录,一共{2}条',
		//item:null,
		emptyMsg:'没有记录'
	})
});

grid.getSelectionModel().on('rowselect', function(sm, rowIdx, r) {

	//var detailPanel = Ext.getCmp('detailPanel');
	
	//bookTpl.overwrite(detailPanel.body, r.data);
	
	//Ext.MessageBox.alert("提示","您选择的出版号是：" + r.data);

});

customerJsonStore.addListener('load',resultCustomer);
function resultCustomer(st, rds, opts){
	//alert(obj2str(opts));
	//alert(opts.params.customerOfficeAdressSearch);
	//alert(customerJsonStore.getCount())
	if(maps)
	{
		maps.clearOverLays();
		clearCustomerArray()
	}
	
	if(customerJsonStore.getAt(0).get('customerOfficeAdressLng') != "" && customerJsonStore.getAt(0).get('customerOfficeAdressLat') != "")
	{
		for(var i=0;i<customerJsonStore.getCount();i++)
		{
			//"id","customerName","customerOfficeAdress","customerOfficeAdressLng","customerOfficeAdressLat","customerStoreHouse","customerStoreHouseLng","customerStoreHouseLat","province","city","district","kehuxiaqu","kehufuzeren","kehufuzerenTel","beizhu"
			if(opts.params.customerOfficeAdressSearch == true && opts.params.customerStoreHouseSearch ==false)
			{
				pointsOffice.push(new LTPoint(customerJsonStore.getAt(i).get('customerOfficeAdressLng'), customerJsonStore.getAt(i).get('customerOfficeAdressLat')));
			}
			else if(opts.params.customerOfficeAdressSearch == false && opts.params.customerStoreHouseSearch ==true)
			{
				pointsHouse.push(new LTPoint(customerJsonStore.getAt(i).get('customerStoreHouseLng'), customerJsonStore.getAt(i).get('customerStoreHouseLat')));
			}
			else
			{
				pointsOffice.push(new LTPoint(customerJsonStore.getAt(i).get('customerOfficeAdressLng'), customerJsonStore.getAt(i).get('customerOfficeAdressLat')));
				pointsHouse.push(new LTPoint(customerJsonStore.getAt(i).get('customerStoreHouseLng'), customerJsonStore.getAt(i).get('customerStoreHouseLat')));
			}
			
			//points.push(new LTPoint(customerJsonStore.getAt(i).get('lag'), customerJsonStore.getAt(i).get('lat')));
			
			ids.push(customerJsonStore.getAt(i).get('id'))
			customerName.push(customerJsonStore.getAt(i).get('customerName'))
			customerOfficeAdress.push(customerJsonStore.getAt(i).get('customerOfficeAdress'))
			customerStoreHouse.push(customerJsonStore.getAt(i).get('customerStoreHouse'))
			province.push(customerJsonStore.getAt(i).get('province'))
			kehuxiaqu.push(customerJsonStore.getAt(i).get('kehuxiaqu'))
			kehufuzeren.push(customerJsonStore.getAt(i).get('kehufuzeren'))
			kehufuzerenTel.push(customerJsonStore.getAt(i).get('kehufuzerenTel'))
			beizhu.push(customerJsonStore.getAt(i).get('beizhu'))
		}
		addAllCustomerMarker(pointsOffice,pointsHouse,ids,customerName,customerOfficeAdress,customerStoreHouse,province,kehuxiaqu,kehufuzeren,kehufuzerenTel,beizhu);
		//maps.getBestMap(pointsArr);
	}
}
//-----------------------------------------客户信息查询结束----------------------------------------


//-----------------------------------------网点查询开始-----------------------------------------------
//客户信息查询
var formWangDianSearch = new Ext.form.FormPanel({
	id: 'formWangDianSearchID',
	name: 'formWangDianSearchID',
	title: '网点信息查询',
	autoHeight: true,
	frame: true,
	layout: "form", // 整个大的表单是form布局
	labelWidth: 60,
	labelAlign: "right",
	items: [
	{
		xtype:"combo",
		fieldLabel: '查询方式',
		id:'searchWayWangDian',
		name:'searchWayWangDian',
		width:120,
		triggerAction:'all',
		displayField: 'text',
		valueField: 'value',
		mode: 'local', 
		emptyText:'请选择',
		store: new Ext.data.SimpleStore({
			fields: ['value', 'text'],
			data: [
				[1, '按销售片区查询'],
				[2, '按行政区划查询']
			]
		}),
		listeners:{
			scope:this,
			select:function(combo){
				var value=combo.getValue();
				//alert(value);
				if(value == 1)
				{
					//alert(Ext.getCmp("codeWangDianPane").hidden);
					//Ext.getCmp("codeWangDian").hideLabel = true;
					//Ext.getCmp("codeWangDian").setVisible(true);
					//Ext.getCmp('codeWangDian').setVisible(true);  
					//Ext.getCmp('codeWangDian').getEl().up('.x-form-item').setDisplayed(true); 
					
					Ext.getCmp("codeWangDianPane").hide();
					Ext.getCmp("saleAreaWangDianPane").show();
					
					citysWinSale(function(arr){
						Ext.getDom("saleAreaWangDian").value = arr[0];
						Ext.getDom("codeWangDian").value = "";
					});
				}
				else
				{
					Ext.getCmp("codeWangDianPane").show();
					Ext.getCmp("saleAreaWangDianPane").hide();
					//Ext.getCmp("saleAreaWangDian").hidden
					
					citysWin(function(arr){
						Ext.getDom("codeWangDian").value = "";
						for(var i=arr.length-1;i>=0;i--)
						{
							if(arr[i]!="root"&&arr[i]!="全国")
							{
								Ext.getDom("codeWangDian").value += arr[i];//设定经度
							}
						}
						Ext.getDom("saleAreaWangDian").value = "";
					});
				}
			}
		}
	},
	//行政区划显示
	{
		hidden:true,
    	id:'codeWangDianPane',
		labelWidth:60,
		xtype:'panel',
		baseCls:"x-plain",
		layout:'form',
		anchor:'95%',
		items:[{
			xtype: 'textfield',
			name:'codeWangDian',
			id:'codeWangDian',
			fieldLabel: '行政区划',
			value:"",
			anchor: '90%'
		}]
	},
	//销售片区显示
	{
		hidden:true,
    	id:'saleAreaWangDianPane',
		labelWidth:60,
		xtype:'panel',
		baseCls:"x-plain",
		layout:'form',
		anchor:'95%',
		items:[{
			xtype: 'textfield',
			name:'saleAreaWangDian',
			id:'saleAreaWangDian',
			fieldLabel: '销售片区',
			value:"",
			anchor: '90%'
		}]
	},
	//类别选取择强束
	{
		xtype: 'textfield',
		name:'customerKeyWordWangDian',
		id:'customerKeyWordWangDian',
		fieldLabel: '关键词',
		anchor: '90%'
	}],
	buttons: [{
		text: '查询',
		handler:function(){
			//alert(formCustomerSearch.form.findField("customerOfficeAdressSearch").getValue());
			//alert(Ext.getCmp("customerOfficeAdressSearch").getValue());
			grid.getBottomToolbar().bind(wangDianJsonStore);//重新绑定分页
			grid.reconfigure(wangDianJsonStore, wangDianList);//重新绑定gridpanel
			
			if(Ext.getCmp("codeWangDianPane").hidden == true && Ext.getCmp("saleAreaWangDianPane").hidden != true)
			{
				searchWayWangDianValue = Ext.getDom("saleAreaWangDian").value;
				xtype = 1;
			}
			else if(Ext.getCmp("saleAreaWangDianPane").hidden == true && Ext.getCmp("codeWangDianPane").hidden != true)
			{
				searchWayWangDianValue = Ext.getDom("codeWangDian").value;
				xtype = 2;
			}
			else
			{
				searchWayWangDianValue = "";
				xtype = 3;
				//return;
			}
			
			wangDianJsonStore.removeAll();
			maps.clearOverLays();
			grid.expand();
			wangDianJsonStore.on('beforeload',function(){
				Ext.apply(
				this.baseParams,
				{
					//provinceWangDian:Ext.getCmp("provinceWangDian").getValue(),
					xtype:xtype,
					searchWayWangDianValue:searchWayWangDianValue,
					customerKeyWordWangDian:Ext.getCmp("customerKeyWordWangDian").getValue()
				});
			});
			wangDianJsonStore.load({
				params: {
					start:0,
					limit:pageSize,
					//provinceWangDian:Ext.getCmp("provinceWangDian").getValue(),
					xtype:xtype,
					searchWayWangDianValue:searchWayWangDianValue,
					customerKeyWordWangDian:Ext.getCmp("customerKeyWordWangDian").getValue()
				}
				,callback:function(r,options,success){if(wangDianJsonStore.getCount() == 0){Ext.MessageBox.alert('提示', "搜索无结果");}}
			})
		}
	}]
});

//客户信息查询列表
var wangDianList = new Ext.grid.ColumnModel([
	{header:'编号',dataIndex:'id'},
	{header:'网点名称',dataIndex:'wangdianName'},
	{header:'所属城市',dataIndex:'province'}
	//{header:'描述',dataIndex:'detail'}
]);

var wangDianJsonStore = new Ext.data.JsonStore({
	url: "json_wangDianInfoSearch_client.asp",
	root: "root",
	totalProperty: 'mytotal',
	//remoteSort:true,
	baseParams:{start:0,limit:pageSize},
	idProperty: "id",
	//fields: ["id", "name", "info","icon","lag","lat","file1"]
	fields: ["id","wangdianName","wangdianAddress","wangdianAddressLng","wangdianAddressLat","province","city","district","saleAreaId","wangdianAreaOwen","wangdianfuzeren","wdfzrTel","wangdianyewuren","wdywrTel","saleId","wangdianPhoto","wangdianOwen","beizhu"]
});

wangDianJsonStore.addListener('load', function(st, rds, opts){
	if(maps)
	{
		//maps.clearOverLays();
		clearWangDianArray()
	}
	
	if(wangDianJsonStore.getAt(0).get('wangdianAddressLng') != "" && wangDianJsonStore.getAt(0).get('wangdianAddressLat') != "")
	{
		for(var i=0;i<wangDianJsonStore.getCount();i++)
		{
			pointsAddress.push(new LTPoint(wangDianJsonStore.getAt(i).get('wangdianAddressLng'), wangDianJsonStore.getAt(i).get('wangdianAddressLat')));
			idsWandDian.push(wangDianJsonStore.getAt(i).get('idsWandDian'));
			wangdianName.push(wangDianJsonStore.getAt(i).get('wangdianName'));
			wangdianAddress.push(wangDianJsonStore.getAt(i).get('wangdianAddress'));
			provinceWangDian.push(wangDianJsonStore.getAt(i).get('province'));
			saleAreaId.push(wangDianJsonStore.getAt(i).get('saleAreaId'));
			wangdianAreaOwen.push(wangDianJsonStore.getAt(i).get('wangdianAreaOwen'));
			wangdianfuzeren.push(wangDianJsonStore.getAt(i).get('wangdianfuzeren'));
			wdfzrTel.push(wangDianJsonStore.getAt(i).get('wdfzrTel'));
			wangdianyewuren.push(wangDianJsonStore.getAt(i).get('wangdianyewuren'));
			wdywrTel.push(wangDianJsonStore.getAt(i).get('wdywrTel'));
			saleId.push(wangDianJsonStore.getAt(i).get('saleId'));
			wangdianPhoto.push(wangDianJsonStore.getAt(i).get('wangdianPhoto'));
			wangdianOwen.push(wangDianJsonStore.getAt(i).get('wangdianOwen'));
			beizhu.push(wangDianJsonStore.getAt(i).get('beizhu'));
		}
		addAllWangDianMarker(pointsAddress,idsWandDian,idsWandDian,wangdianName,wangdianAddress,provinceWangDian,saleAreaId,wangdianAreaOwen,wangdianfuzeren,wdfzrTel,wangdianyewuren,wdywrTel,saleId,wangdianPhoto,wangdianOwen,beizhu);
		//maps.getBestMap(pointsArr);
	}
});
//-----------------------------------------网点查询结束----------------------------------------

//-----------------------------------------采集查询开始-----------------------------------------------
//采集网点信息查询
var formCaiJiSearch = new Ext.form.FormPanel({
	id: 'formCaiJiSearchID',
	name: 'formCaiJiSearchID',
	title: '采集网点信息查询',
	autoHeight: true,
	frame: true,
	layout: "form", // 整个大的表单是form布局
	labelWidth: 60,
	labelAlign: "right",
	items: [
	//类别选取择强束
	{
		xtype: 'textfield',
		name:'customerKeyWordCaiJi',
		id:'customerKeyWordCaiJi',
		fieldLabel: '关键词',
		anchor: '90%'
	}],
	buttons: [{
		text: '查询',
		handler:function(){
			//alert(formCustomerSearch.form.findField("customerOfficeAdressSearch").getValue());
			//alert(Ext.getCmp("customerOfficeAdressSearch").getValue());
			grid.getBottomToolbar().bind(caiJiJsonStore);//重新绑定分页
			grid.reconfigure(caiJiJsonStore, caiJiList);//重新绑定gridpanel
			
			caiJiJsonStore.removeAll();
			maps.clearOverLays();
			grid.expand();
			caiJiJsonStore.on('beforeload',function(){
				Ext.apply(
				this.baseParams,
				{
					//provinceCaiJi:Ext.getCmp("provinceCaiJi").getValue(),
					//xtype:xtype,
					customerKeyWordCaiJi:Ext.getCmp("customerKeyWordCaiJi").getValue()
				});
			});
			caiJiJsonStore.load({
				params: {
					start:0,
					limit:pageSize,
					//provinceCaiJi:Ext.getCmp("provinceCaiJi").getValue(),
					//xtype:xtype,
					customerKeyWordCaiJi:Ext.getCmp("customerKeyWordCaiJi").getValue()
				}
				,callback:function(r,options,success){if(caiJiJsonStore.getCount() == 0){Ext.MessageBox.alert('提示', "搜索无结果");}}
			})
		}
	}]
});

//客户信息查询列表
var caiJiList = new Ext.grid.ColumnModel([
	{header:'编号',dataIndex:'id'},
	{header:'网点名称',dataIndex:'wangdianName'},
	{header:'网点编号',dataIndex:'wangdianNumber'},
	{header:'重要地标名称',dataIndex:'landmarksName'},
	{header:'地址',dataIndex:'positionAddress'},
	{header:'经度',dataIndex:'lng'},
	{header:'纬度',dataIndex:'lat'}
]);

var caiJiJsonStore = new Ext.data.JsonStore({
	url: "json_getPositionMsgInfoSearch_client.asp",
	root: "root",
	totalProperty: 'mytotal',
	//remoteSort:true,
	baseParams:{start:0,limit:pageSize},
	idProperty: "id",
	//fields: ["id", "name", "info","icon","lag","lat","file1"]
	fields: ["id","wangdianName","wangdianNumber","landmarksName","positionAddress","lng","lat","wangdianPhone"]
});

caiJiJsonStore.addListener('load', function(st, rds, opts){
	if(maps)
	{
		//maps.clearOverLays();
		clearCaiJiArray()
	}
	
	if(caiJiJsonStore.getAt(0).get('lng') != "" && caiJiJsonStore.getAt(0).get('lat') != "")
	{
		
		for(var i=0;i<caiJiJsonStore.getCount();i++)
		{
			if (!(/(^[1-9]\d*$)/.test(caiJiJsonStore.getAt(i).get('lng'))))
			{
				caiJiPoints.push(new LTPoint(caiJiJsonStore.getAt(i).get('lng')*100000, caiJiJsonStore.getAt(i).get('lat')*100000));
			}
			caiJiIDS.push(caiJiJsonStore.getAt(i).get('id'));
			caiJiWangDianName.push(caiJiJsonStore.getAt(i).get('wangdianName'));
			caiJiWangDianNumber.push(caiJiJsonStore.getAt(i).get('wangdianNumber'));
			caiJiLandmarksName.push(caiJiJsonStore.getAt(i).get('landmarksName'));
			caiJiPositionAddress.push(caiJiJsonStore.getAt(i).get('positionAddress'));
			caiJiWangdianPhone.push(caiJiJsonStore.getAt(i).get('wangdianPhone'));
		}
		addAllCaiJiMarker(caiJiPoints,caiJiIDS,caiJiWangDianName,caiJiWangDianNumber,caiJiLandmarksName,caiJiPositionAddress,caiJiWangdianPhone);
		//maps.getBestMap(pointsArr);
	}
});

function addAllCaiJiMarker(caiJiPoints,caiJiIDS,caiJiWangDianName,caiJiWangDianNumber,caiJiLandmarksName,caiJiPositionAddress,caiJiWangdianPhone)
{
	for(var i=0;i<caiJiIDS.length;i++)
	{
		//alert(caiJiPoints[i].getLongitude()+"||"+caiJiPoints[i].getLatitude());
		//alert(customerName[i]);
		var html="网点名称："+caiJiWangDianName[i]+"<br>";
		html+="网点编号："+caiJiWangDianNumber[i]+"<br>";
		html+="重要地标名称："+caiJiLandmarksName[i]+"<br>";
		html+="地址："+caiJiPositionAddress[i]+"<br>";
		html+="<img src='"+caiJiWangdianPhone[i]+"' onerror='this.src=\"images/noimg.jpg\"' target='_blank' onmouseover='imgZoomIn(this)' onmouseout='imgZoomOut(this)' style='width:210px;height:160px;'/>";
		var iconUrl="icons/kehu.png";
		var icon2=new LTIcon(iconUrl,[30,30],[15,30]);//创建一个图标
		var marker = new LTMarker(caiJiPoints[i],icon2);
		maps.addOverLay(marker);
		html="<div style='text-align:left'>"+html+"</div>"
		LTEvent.addListener(marker,"click",getClickCallBackCaiJi(marker,html,caiJiWangDianName[i],i));
	}
	maps.getBestMap(caiJiPoints);
	grid.on('rowmousedown',function(a,b,c){
		if(caiJiJsonStore.getAt(b))
		{
			
			for(var i=0;i<markerChange.length;i++)
			{
				maps.removeOverLay(markerChange[i]);
			}
			
			var html="网点名称："+caiJiWangDianName[b]+"<br>";
			html+="网点编号："+caiJiWangDianNumber[b]+"<br>";
			html+="重要地标名称："+caiJiLandmarksName[b]+"<br>";
			html+="地址："+caiJiPositionAddress[b]+"<br>";
			
			var iconUrl="icons/kehu2.png";
			var icon2=new LTIcon(iconUrl,[30,30],[15,30]);//创建一个图标
			var marker = new LTMarker(caiJiPoints[b],icon2);
			maps.addOverLay(marker);
			html="<div style='text-align:left'>"+html+"</div>"
			LTEvent.addListener(marker,"click",getClickCallBackCaiJi(marker,html,caiJiWangDianName[b],b));
			markerChange.push(marker);
			marker.getObject().style.zIndex=520;
			
			if (!(/(^[1-9]\d*$)/.test(caiJiJsonStore.getAt(b).get('lng'))))
			{
				maps.moveToCenter(new LTPoint(caiJiJsonStore.getAt(b).get('lng')*100000, caiJiJsonStore.getAt(b).get('lat')*100000));
			}
			//maps.moveToCenter(new LTPoint(caiJiJsonStore.getAt(b).get('lng'), caiJiJsonStore.getAt(b).get('lat')),17);
		}
	});
}

//鼠标浮动及单击事件方法
function getClickCallBackCaiJi(marker,html,name,i)
{
	return function(){
		var infoWin=marker.openInfoWinHtml(html); infoWin.setTitle(name);
		//marker.getObject().style.zIndex=520;
		//grid.getView().getRow(i).style.backgroundColor='#DCDCDC';
	}
}
//-----------------------------------------采集查询结束----------------------------------------

//-----------------------------------------人员定位信息开始-----------------------------------------------
//行程信息查询
var formUploadPositionSearch = new Ext.form.FormPanel({
	id: 'formUploadPositionSearchID',
	name: 'formUploadPositionSearchID',
	title: '人员定位',
	autoHeight: true,
	frame: true,
	layout: "form", // 整个大的表单是form布局
	labelWidth: 60,
	labelAlign: "right",
	items: [
		{xtype: 'button',handler:function(){window.open("position.asp");},text:'打开人员定位详细页面',width: 120,height:22}
	]
});
//-----------------------------------------人员定位信息结束-----------------------------------------------

//-----------------------------------------人员定位信息开始-----------------------------------------------
//行程信息查询
var formTracksSearch = new Ext.form.FormPanel({
	id: 'formTracksSearchID',
	name: 'formTracksSearchID',
	title: '轨迹查询',
	autoHeight: true,
	frame: true,
	layout: "form", // 整个大的表单是form布局
	labelWidth: 60,
	labelAlign: "right",
	items: [
		{xtype: 'button',handler:function(){window.open("tracks.asp");},text:'打开轨迹查询详细页面',width: 120,height:22}
	]
});
//-----------------------------------------人员定位信息结束-----------------------------------------------

//-----------------------------------------行程信息查询开始-----------------------------------------------
//行程信息查询
var formRoadSearch = new Ext.form.FormPanel({
	id: 'formRoadSearchID',
	name: 'formRoadSearchID',
	title: '行程信息查询',
	autoHeight: true,
	frame: true,
	layout: "form", // 整个大的表单是form布局
	labelWidth: 60,
	labelAlign: "right",
	items: [
		{xtype: 'button',handler:function(){window.open("route.asp");},text:'打开行程详细页面',width: 120,height:22}
	]
});

//行程信息查询列表
var roadList = new Ext.grid.ColumnModel([
	{header:'编号',dataIndex:'id'},
	{header:'标题',dataIndex:'roadTitle'},
	{header:'起点经度',dataIndex:'lng'}
	,
	{header:'起点纬度',dataIndex:'lat'},
	{header:'日期',dataIndex:'roadDate'},
	{header:'访问客户或网点',dataIndex:'roadTarget'},
	{header:'客户或网点所属客户',dataIndex:'cityName'},
	{
		header:'公交',
		dataIndex:'gongjiao',
		width:60,
		renderer:gongJiaoFun
	},
	{
		header:'导航',
		dataIndex:'daoHang',
		width:60,
		renderer:daoHangFun
	}
	/*,
	{
		header:'清除',
		dataIndex:'qingChu',
		width:60,
		renderer:shanChuFun
	}*/
]);

//公交按钮
function gongJiaoFun(value,cellmeta,record,rowIndex,columnIndex,store)
{
	var str="<input type='button' value='公交' onclick='gongJiaoFunDo(\""+escape(record.data["id"])+"\",\""+escape(record.data["roadTitle"])+"\",\""+escape(record.data["lng"])+"\",\""+escape(record.data["lat"])+"\",\""+escape(record.data["roadDate"])+"\",\""+escape(record.data["roadTarget"])+"\",\""+escape(record.data["cityName"])+"\")'\>"
	//alert(str);
	return str;
}

//全局变量
var map, //51ditu的Map对象
bus, //公交接口变量
routeResult, //公交换乘方案结果
spoint, //公交换乘方案的起始坐标点
epoint, //公交换乘方案的目标坐标点
iconUrl = 'http:\/\/api.51ditu.com\/img\/bus\/point1.gif'; //自定义图片路径

//----------------------公交查询开始------------------------------------
function gongJiaoFunDo(id,roadTitle,lng,lat,roadDate,roadTarget,cityName)
{
	//alert(cityName);
	var self = this;
	//alert(unescape(cityName));
	Ext.Ajax.request({
		url:'json_gongJiaoSearch.asp',
		method:'post',
		params:{
			roadTarget:roadTarget
		},
		success:function(req){
			//alert(req.responseText);
			maps.clearOverLays();
			var obj = req.responseText;
			if(obj.indexOf("|") != -1)
			{
				var objArr = obj.split("|");
				
				var slnglat = new LTPoint(parseInt(lng),parseInt(lat));
				spoint = slnglat
				var elnglat = objArr[0].split(",");
				epoint = new LTPoint(parseInt(elnglat[0]),parseInt(elnglat[1]));
				//alert(slnglat.getLongitude()+","+slnglat.getLatitude()+"|===|"+epoint.getLongitude()+","+epoint.getLatitude());
				bus = new LTBus(); //新建一个公交接口对象
				bus.setCity(unescape(cityName)); //设置公交所在城市
				LTEvent.addListener(bus,'routesloaded',function(result){
					routeResult = result;
					if(routeResult.routes)
					{
						var route = routeResult.routes[0];
						bus.getRouteDetail(route); //通过换乘方案对象获取此换乘方案的详细信息参数类型为LTBusRoute
					}
					else
					{
						alert("无公交");
					}
				}); //绑定公交换乘方案信息加载后，调用routesLoaded函数
				LTEvent.addListener(bus,"routedetailloaded",onRouteDetailLoadedBus);
				bus.getRoutesByPoint(slnglat,epoint);//根据起始坐标点/站点，获取换乘方案
				
				for(var i=0;i<objArr.length;i++)
				{
					if((i+1)<objArr.length)
					{
						var slnglat = objArr[i].split(",");
						var elnglat = objArr[i+1].split(",");
						if(slnglat.length === 1){//判断是坐标点还是站点名称
							spoint = slnglat[0];
						}else{
							spoint = new LTPoint(slnglat[0],slnglat[1]);
						}
						if(elnglat.length === 1){//判断是坐标点还是站点名称
							epoint = elnglat[0];
						}else{
							epoint = new LTPoint(elnglat[0],elnglat[1]);
						}
						//alert(slnglat[0]+","+slnglat[1]+"||"+elnglat[0]+","+elnglat[1]);
						bus = new LTBus(); //新建一个公交接口对象
						bus.setCity(unescape(cityName)); //设置公交所在城市
						LTEvent.addListener(bus,'routesloaded',routesLoadedBus); //绑定公交换乘方案信息加载后，调用routesLoaded函数
						LTEvent.addListener(bus,"routedetailloaded",onRouteDetailLoadedBus);
						bus.getRoutesByPoint(spoint,epoint);//根据起始坐标点/站点，获取换乘方案
					}
				}
			}
			else
			{
				var elnglat = obj.split(",");
				spoint = new LTPoint(lng,lat);
				if(elnglat.length === 1){//判断是坐标点还是站点名称
					epoint = elnglat[0];
				}else{
					epoint = new LTPoint(elnglat[0],elnglat[1]);
				}
				bus = new LTBus(); //新建一个公交接口对象
				bus.setCity(unescape(cityName)); //设置公交所在城市
				LTEvent.addListener(bus,'routesloaded',routesLoadedBus); //绑定公交换乘方案信息加载后，调用routesLoaded函数
				LTEvent.addListener(bus,"routedetailloaded",onRouteDetailLoadedBus);
				bus.getRoutesByPoint(spoint,epoint);//根据起始坐标点/站点，获取换乘方案
			}
		}
	});
}

function routesLoadedBus(result)
{
	routeResult = result;
	if(routeResult.routes)
	{
		var route = routeResult.routes[0];
		bus.getRouteDetail(route); //通过换乘方案对象获取此换乘方案的详细信息参数类型为LTBusRoute
	}
	else
	{
		alert("无公交");
	}
}

//在获取到点的详细信息时执行的操作
function onRouteDetailLoadedBus(routes)
{
	//alert(routes);
	drawRouteBus(routes); //显示换乘方案
	//showStartAndEndBus(); //在地图上显示起点坐标和终点坐标
}
//在地图上显示换乘轨迹
function drawRouteBus(routes)
{
	//alert("return="+routes.routeLines.length);
	//maps.clearOverLays();
	var totalPoint = []; //此换乘方案的所有坐标点
	var colors = ['green','blue','red'];
	var sePoint = [];//当前请求线路步行的起始点集合
	sePoint.push(spoint); //把此换乘起始坐标点放入数组
	for(var i = 0;i < routes.routeLines.length; i++){
		var routeLine = routes.routeLines[i];
		sePoint.push(routeLine.sStation.point); //把换乘中的公交线路的起始坐标点放入数组
		sePoint.push(routeLine.eStation.point); //把换乘中的公交线路的终点坐标点放入数组
		for(var j = 0; j<routeLine.stations.length; j++){
			//在地图上显示所有的公交站点名称
			maps.addOverLay(createMarker(routeLine.stations[j].point,routeLine.stations[j].name));
			//显示经过站点的自定义图标
			maps.addOverLay(createIcon(routeLine.stations[j].point));
			
			totalPoint.push(routeLine.stations[j].point)
		}
		maps.addOverLay(new LTPolyLine(routeLine.points,'blue')); //在地图上显示公交线路轨迹
	}
	sePoint.push(epoint);  //把此换乘最终坐标点放入数组
	//drawWalk(sePoint);
	//maps.getBestMap(totalPoint);
}
//显示起点和终点的位置
function showStartAndEndBus()
{
	//起点
	maps.addOverLay(createSpecialText(spoint,'起点'));
	maps.addOverLay(createIcon(spoint));
	
	//终点
	maps.addOverLay(createSpecialText(epoint,'终点'));
	maps.addOverLay(createIcon(epoint));
}
//创建起点终点的特殊样式
function createSpecialText(point,txt)
{
	var maptxt = new LTMapText(point,[-5,-20]);
	maptxt.setLabel(txt);
	maptxt.setBackgroundColor("green");//更改文字标签背景色
	maptxt.setFontColor("#fff"); 		//更改文字字体颜色
	return maptxt;
}
//显示出需要步行的路段轨迹
function drawWalk(sePoint)
{
	while(sePoint.length>0){
		//把所有起始点重新组合，把上一线路的终点或者换乘的起始点作为步行路段的起点，下一线路的起始点或者目的地作为步行路段终点
		var a = sePoint.splice(0,2); 
		//alert(a.getLongitude()+"||||"+a.getLatitude());
		maps.addOverLay(new LTPolyLine(a,'green'));//显示步行路段的轨迹
	}
}
//显示站点坐标自定义图标
function createIcon(point){
	var icon=new LTIcon(iconUrl,[9,9],[4,4]);	
	var marker = new LTMarker(point ,icon);
	return marker;
}
//显示站点名称
function createMarker(point,txt){
	var icon=new LTIcon(iconUrl,[9,9],[0,30]);
	var marker=new LTMarker(point,icon);
	marker.setLabel('<div class="zhandian01"><div class="zhandian02">'+txt+'</div></div>');
	return marker;
}
//----------------------公交查询结束------------------------------------


//导航按钮
function daoHangFun(value,cellmeta,record,rowIndex,columnIndex,store)
{
	var str="<input type='button' value='导航' onclick='daoHangFunDo(\""+escape(record.data["id"])+"\",\""+escape(record.data["roadTitle"])+"\",\""+escape(record.data["lng"])+"\",\""+escape(record.data["lat"])+"\",\""+escape(record.data["roadDate"])+"\",\""+escape(record.data["roadTarget"])+"\",\""+escape(record.data["cityName"])+"\")'\>"
	//alert(str);
	return str;
}


var nav;	//导航对象
//var info;	//信息框对象
var points = [];	//导航关键点集合的经纬度
var startControl;	//起始标注点控件对象
var endControl;		//终点标注点控件对象
var startPoint = "";	//起始点坐标
var endPoint = "";		//终点坐标
var line;	//导航线路

//导航查询
function daoHangFunDo(id,roadTitle,lng,lat,roadDate,roadTarget,cityName)
{
	Ext.Ajax.request({
		url:'json_gongJiaoSearch.asp',
		method:'post',
		params:{
			roadTarget:roadTarget
		},
		success:function(req){
			//alert(req.responseText);
			maps.clearOverLays();
			var obj = req.responseText;
			
			if(obj.indexOf("|") != -1)
			{
				var objArr = obj.split("|");
				
				var slnglat = new LTPoint(parseInt(lng),parseInt(lat));
				startPoint = slnglat
				var elnglat = objArr[0].split(",");
				endPoint = new LTPoint(parseInt(elnglat[0]),parseInt(elnglat[1]));
				//alert(slnglat.getLongitude()+","+slnglat.getLatitude()+"|===|"+epoint.getLongitude()+","+epoint.getLatitude());
				
				//创建导航对象，run为接收返回值参数的函数
				nav = new LTNavigate(run);
				// 设置起点坐标 保存到导航对象中 
				nav.setFrom(startPoint);
				//设置终点坐标 
				nav.setTo(endPoint);
				//开始导航,默认为推荐线路
				nav.navigate(0);
				
				for(var i=0;i<objArr.length;i++)
				{
					if((i+1)<objArr.length)
					{
						var slnglat = objArr[i].split(",");
						var elnglat = objArr[i+1].split(",");
						startPoint = new LTPoint(slnglat[0],slnglat[1]);
						endPoint = new LTPoint(elnglat[0],elnglat[1]);
						//创建导航对象，run为接收返回值参数的函数
						nav = new LTNavigate(run);
						// 设置起点坐标 保存到导航对象中
						nav.setFrom(startPoint);
						//设置终点坐标 
						nav.setTo(endPoint);
						//开始导航,默认为推荐线路
						nav.navigate(0);
					}
				}
			}
			else
			{
				var elnglat = obj.split(",");
				startPoint = new LTPoint(lng,lat);
				endPoint = new LTPoint(elnglat[0],elnglat[1]);
				//创建导航对象，run为接收返回值参数的函数
				nav = new LTNavigate(run);
				// 设置起点坐标 保存到导航对象中
				nav.setFrom(startPoint);
				//设置终点坐标 
				nav.setTo(endPoint);
				//开始导航,默认为推荐线路
				nav.navigate(0);
			}
		}
	});
}

/*
*   接收导航返回值参数的函数，resultObj为导航返回的对象
*/
function run(resultObj){
	var obj = resultObj;
	//获得导航线路坐标集合
	var roads = obj.getRoadTrack();
	maps.removeOverLay(line);
	//创建画线对象
	var line = new LTPolyLine(roads);
	//向地图上添加线
	maps.addOverLay(line);
	//清空显示列表
	//document.getElementById("poisInfo").innerHTML="";
	//获得关键点描述对象
	var kpois = obj.getKeyPoints();
	for(var i=0;i<kpois.length;i++){
		//显示关键点描述内容
		createLine(kpois[i],i+1);
	}
}

/*
* 显示关键点描述内容，obj关键点对象，num为编号
*/
function createLine(obj,num){
	var o = obj;
	//判断概要信息中是否存在详细描述，如果存在显示详细描述
	if(obj.getExists()){
		//打开与关闭图标
		//toCenter(obj.getPoint(),obj.getDescription());
		var icon=new LTIcon(iconUrl,[9,9],[4,4]);
		var marker=new LTMarker(obj.getPoint(),icon);
		maps.addOverLay(marker);
		LTEvent.addListener(marker,"click",function(){
			//创建信息框对象
			var info = new LTInfoWindow();
			//设置信息框的经纬度
			info.setPoint(obj.getPoint());
			//设置信息框的内容简介
			info.setLabel(obj.getDescription());
			//将信息框添加到地图上
			maps.addOverLay(info);
		});
		points.push(obj.getPoint());
		
		//判断概要信息中是否存在详细描述，如果存在显示详细描述
		var kps = obj.getDetailedDescription();
		for(var i=0;i<kps.length;i++){
			(function(i){
				var lo = kps[i].lo; //经度
				var la = kps[i].la; //纬度
				var point = new LTPoint(lo,la);
				var des = kps[i].contentMerge;
				//toCenter(point,des);
				var icon=new LTIcon(iconUrl,[9,9],[4,4]);
				var marker=new LTMarker(point,icon);
				maps.addOverLay(marker);
				LTEvent.addListener(marker,"click",function(){
					//创建信息框对象
					var info = new LTInfoWindow();
					//设置信息框的经纬度
					info.setPoint(point);
					//设置信息框的内容简介
					info.setLabel(des);
					//将信息框添加到地图上
					maps.addOverLay(info);
				});
				points.push(point);
			})(i);
		}
		//document.getElementById("poisInfo").appendChild(div);
	}else{	//如果概要中没有详细信息，只显示概要信息
		//显示导航概要信息描述
		//toCenter(obj.getPoint(),obj.getDescription());
		var icon=new LTIcon(iconUrl,[9,9],[4,4]);
		var marker=new LTMarker(obj.getPoint(),icon);
		maps.addOverLay(marker);
		LTEvent.addListener(marker,"click",function(){
			//创建信息框对象
			var info = new LTInfoWindow();
			//设置信息框的经纬度
			info.setPoint(obj.getPoint());
			//设置信息框的内容简介
			info.setLabel(obj.getDescription());
			//将信息框添加到地图上
			maps.addOverLay(info);
		});
		points.push(obj.getPoint());
	}
	//将导航线路显示在地图内
	maps.getBestMap(points);
}

/*
* 将描述信息显示到地
*
**/
function toCenter(p,ifo){
	//显示到地图中心点
	//maps.moveToCenter(p);
	
	
	
	var icon=new LTIcon(iconUrl,[9,9],[4,4]);
	var marker=new LTMarker(p,icon);
	maps.addOverLay(marker);
	
	LTEvent.addListener(marker,"click",infoWindow);
	
	/*//创建信息框对象
	var info = new LTInfoWindow();
	//设置信息框的经纬度
	info.setPoint(p);
	//设置信息框的内容简介
	info.setLabel(ifo);
	//将信息框添加到地图上
	maps.addOverLay(info);*/
}

function infoWindow()
{
	
}

















//清除按钮
function shanChuFun(value,cellmeta,record,rowIndex,columnIndex,store)
{
	var str="<input type='button' value='清除' onclick='shanChuFunDo(\""+escape(record.data["id"])+"\",\""+escape(record.data["roadTitle"])+"\",\""+escape(record.data["lng"])+"\",\""+escape(record.data["lat"])+"\",\""+escape(record.data["roadDate"])+"\",\""+escape(record.data["roadTarget"])+"\",\""+escape(record.data["cityName"])+"\")'\>"
	//alert(str);
	return str;
}

//清除
function shanChuFunDo(id,roadTitle,lng,lat,roadDate,roadTarget)
{
	
}


var roadJsonStore = new Ext.data.JsonStore({
	url: "json_roadInfoSearch_client.asp",
	root: "root",
	totalProperty: 'mytotal',
	//remoteSort:true,
	baseParams:{start:0,limit:pageSize},
	idProperty: "id",
	//fields: ["id", "name", "info","icon","lag","lat","file1"]
	fields: ["id","roadTitle","lng","lat","roadDate","roadTarget","cityName"]
});
//-----------------------------------------行程信息查询结束----------------------------------------

//-------------全国城市列表开始-----------------------------
//城市列表窗口，参数type为树是否有复选框，1表示没有，2表示有
function citysWin(fun,type)
{
	citys_form_obj = citysForm(fun,type);
	citys_win = new Ext.Window({title: "城市列表",width: 213,height:375,modal: true,maximizable: false,resizable:false,items: citys_form_obj});
	citys_win.show();
}
function citysForm(fun,type)
{
	if(typeof type == "undefined" || type !=2 || type ==1)
	{
		var treeJSON = citys_tree_obj;
	}
	else
	{
		var treeJSON = citys_tree_obj_checked;
	}
	//全国的城市列表
	var treeCitys = new Ext.tree.TreePanel({
		//el: 'tree',
		//loader: new Ext.tree.TreeLoader({dataUrl:"citys/tree.asp"}),
		loader: new Ext.tree.TreeLoader(),
		//title: '系统管理',
		split: true,
		//border: true,
		rootVisible:false,
		autoScroll: true,
		//autoScroll:false,
		//collapsible: true,
		enableAllCheck:true,	//给树增加复选框
		width: 200,
		height:300
		//,
		//minSize: 80
	});
	
	var root = new Ext.tree.AsyncTreeNode({
		text:'root'
		,
		children: treeJSON
	});
	
	// 设置树的点击事件
	function treeClick(node, e)
	{
		//alert(node.text);
		
		//获取所有子节点
		/*node.cascade( function( node ){
			node.attributes.checked = flag;
			node.ui.checkbox.checked = flag;
			return true;
		});*/
		nodeCity = [];
		nodeCity.push(node.text);
		try
		{
			//获取所有父节点
			var pNode = node.parentNode;
			for(;pNode.id !="root";pNode = pNode.parentNode ){
				//alert(pNode.text);
				if (treeCitys.getChecked(id, node.parentNode) == "")
				{
					//alert(pNode.text);
					if(pNode.text!="root"&&pNode.text!="全国")
					{
						nodeCity.push(pNode.text);
					}
					//pNode.ui.checkbox.checked = flag;
					//pNode.attributes.checked = flag;
				}
			}
		}catch(e){}
	}
	// 增加鼠标单击事件
	treeCitys.on('click', function(node,e){
		nodeCity = [];
		nodeCity.push(node.text);
		try
		{
			//获取所有父节点
			var pNode = node.parentNode;
			for(;pNode.id !="root";pNode = pNode.parentNode ){
				if (treeCitys.getChecked(id, node.parentNode) == "")
				{
					if(pNode.text!="root"&&pNode.text!="全国")
					{
						nodeCity.push(pNode.text);
					}
				}
			}
		}catch(e){}							   
	});
	// 增加复选框架单击事件
	treeCitys.on('checkchange', function(node, checked){
		
		//nodeCityChecked = [];
		
		if(checked == false)
		{
			removeStr(nodeCityChecked,node.text);	
			return;
		}
		
		nodeCityChecked.push(node.text);
		/*try	//预留防止客户更改业务
		{
			//获取所有父节点
			var pNode = node.parentNode;
			for(;pNode.id !="root";pNode = pNode.parentNode ){
				alert(pNode.text);
				if (checked || treeCitys.getChecked(id, node.parentNode) == "")
				{
					if(pNode.text!="root"&&pNode.text!="全国")
					{
						nodeCityChecked.push(pNode.text);
					}
					pNode.ui.checkbox.checked = checked;
					pNode.attributes.checked = checked;
				}
			}
		}catch(e){}*/
	});
	
	treeCitys.setRootNode(root);
	treeCitys.expand();
	//root.reload();
	//Ajax提交新增请求后，在callback中刷新treeCitys的根节点，然后定位到当前节点
	//var path = currentNode.getPath('id');
	//treeCitys.getRootNode().reload();	//刷新树
	//treeCitys.expandPath(path,'id');
	
	var nodeCity = [];	//不带复选框返回的值
	var nodeCityChecked = [];	//带复选框返回的值
	var form1 = new Ext.form.FormPanel({
		width:200,
		//height:200,
		//frame:true,//圆角和浅蓝色背景
		//renderTo:Ext.getBody(),//呈现
		//title:"FormPanel",
		//bodyStyle:"padding:5px 5px 0",
		//defaults:{xtype:"textfield",width:120},
		items:[
			treeCitys
		],
		buttons:[
			{text:"确定",handler:function(){
				if(typeof type == "undefined" || type !=2 || type ==1)
				{
					//不带复选框返回的值
					fun(nodeCity);
				}
				else
				{
					//带复选框返回的值
					fun(nodeCityChecked);
				}
				
				citys_win.close()}
			},
			{text:"取消",handler:function(){citys_win.close()}}]
	});
	return form1;
}

function citysWinSale(fun,type)
{
	citysSale_form_obj = citysFormSale(fun,type);
	citysSale_win = new Ext.Window({title: "城市列表",width: 213,height:375,modal: true,maximizable: false,resizable:false,items: citysSale_form_obj});
	citysSale_win.show();
}

//treeSaleArea.expand(true);

function citysFormSale(fun,type)
{
	
	var treeSaleArea = new Ext.tree.TreePanel({
		//loader: new Ext.tree.TreeLoader({url:'json_saleAreaTree.asp'}),
		//renderTo:form1,
		//el:"tree-panel",
		split: true,
		rootVisible:false,
		autoScroll: true,
		width: 200,
		height:300,
		border:false,
		//root:new Ext.tree.AsyncTreeNode({text:'treeRoot',id:'0'})})
		autoScroll: true,
		loader: new Ext.tree.TreeLoader({
			dataUrl: 'json_saleAreaTree.asp'
			//,requestMethod: 'get'//////////
		}),
		root: new Ext.tree.AsyncTreeNode({
			text: 'root',
			//id: 'myCompany',
			expanded: true
		})
	});
	
	// 增加鼠标单击事件
	treeSaleArea.on('click', function(node,e){
		nodeCity = [];
		//nodeCity.push(node.leaf);
		nodeCity.push(node.text);
		try
		{
			//获取所有父节点
			var pNode = node.parentNode;
			for(;pNode.id !="root";pNode = pNode.parentNode ){
				if (treeCitys.getChecked(id, node.parentNode) == "")
				{
					if(pNode.text!="root"&&pNode.text!="全国")
					{
						nodeCity.push(pNode.text);
					}
				}
			}
		}catch(e){}
	});
	
	var nodeCity = [];	//不带复选框返回的值
	var form1 = new Ext.form.FormPanel({
		width:200,
		items:[
			treeSaleArea
		],
		buttons:[
			{text:"确定",handler:function(){
				if(typeof type == "undefined" || type !=2 || type ==1)
				{
					//不带复选框返回的值
					fun(nodeCity);
				}
				else
				{
					//带复选框返回的值
					fun(nodeCityChecked);
				}
				citysSale_win.close()}
			},
			{text:"取消",handler:function(){citysSale_win.close()}}]
	});
	return form1;
}

//-------------全国城市列表结束-----------------------------

function addAllCustomerMarker(pointsOffice,pointsHouse,ids,customerName,customerOfficeAdress,customerStoreHouse,province,kehuxiaqu,kehufuzeren,kehufuzerenTel,beizhu){
	//alert(pointsOffice.length+"||"+pointsHouse <= 0);
	for(var i=0;i<ids.length;i++)
	{
		//alert(customerName[i]);
		var html="客户名称："+customerName[i]+"<br>";
		html+="所在城市："+province[i]+"<br>";
		
		
		html+="客户辖区："+kehuxiaqu[i]+"<br>";
		html+="客户负责人："+kehufuzeren[i]+"<br>";
		html+="客户负责人联系方式："+kehufuzerenTel[i]+"<br>";
		html+="备注信息："+beizhu[i]+"<br>";
		
		if(pointsOffice.length > 0 && pointsHouse.length <= 0)
		{
			html+="客户办公地址："+customerOfficeAdress[i]+"<br>";
			var iconUrl="icons/qita/chuzu.gif";
			var icon2=new LTIcon(iconUrl,[20,20],[20,3]);//创建一个图标
			var marker = new LTMarker(pointsOffice[i],icon2);
			maps.addOverLay(marker);
			html="<div style='text-align:left'>"+html+"</div>"
			LTEvent.addListener( marker , "click" ,getClickCallBackCustomer(marker,html,customerName[i],i));
		}
		else if(pointsOffice.length <= 0 && pointsHouse.length > 0)
		{
			html+="客户仓库地址："+customerStoreHouse[i]+"<br>";
			var iconUrl="icons/youku/chuzu.gif";
			var icon2=new LTIcon(iconUrl,[20,20],[20,3]);//创建一个图标
			var marker = new LTMarker(pointsHouse[i],icon2);
			maps.addOverLay(marker);
			html="<div style='text-align:left'>"+html+"</div>"
			LTEvent.addListener( marker , "click" ,getClickCallBackCustomer(marker,html,customerName[i],i));
		}
		else
		{
			var office = "客户办公地址："+customerOfficeAdress[i]+"<br>";
			var iconUrl="icons/qita/chuzu.gif";
			var icon2=new LTIcon(iconUrl,[20,20],[20,3]);//创建一个图标
			var marker1 = new LTMarker(pointsOffice[i],icon2);
			maps.addOverLay(marker1);
			var htmloffice="<div style='text-align:left'>"+html+office+"</div>"
			LTEvent.addListener( marker1 , "click" ,getClickCallBackCustomer(marker1,htmloffice,customerName[i],i));
			
			var toreHouse = "客户仓库地址："+customerStoreHouse[i]+"<br>";
			var iconUrl="icons/youku/chuzu.gif";
			var icon2=new LTIcon(iconUrl,[20,20],[20,3]);//创建一个图标
			var marker2 = new LTMarker(pointsHouse[i],icon2);
			maps.addOverLay(marker2);
			var htmltoreHouse="<div style='text-align:left'>"+html+toreHouse+"</div>"
			LTEvent.addListener( marker2 , "click" ,getClickCallBackCustomer(marker2,htmltoreHouse,customerName[i],i));
		}
		
		//var customerName=customerName[i];
		//正确写法
		
		//LTEvent.addListener( marker , "mouseover" ,getMouseOverCallBack(i));
		//LTEvent.addListener( maps , "resize" ,function(){alert("map resize");maps.resizeMapDiv()}); 
	}
	
	if(pointsOffice.length > 0 && pointsHouse.length <= 0)
	{
		maps.getBestMap(pointsOffice);
		grid.on('rowmousedown',function(a,b,c){
			if(roadJsonStore.getAt(b))
			{
				maps.moveToCenter(new LTPoint(roadJsonStore.getAt(b).get('customerOfficeAdressLng'), roadJsonStore.getAt(b).get('customerOfficeAdressLat')),17);
			}
		});
	}
	else if(pointsOffice.length <= 0 && pointsHouse.length > 0)
	{
		maps.getBestMap(pointsHouse);
		grid.on('rowmousedown',function(a,b,c){
			if(roadJsonStore.getAt(b))
			{
				maps.moveToCenter(new LTPoint(roadJsonStore.getAt(b).get('customerStoreHouseLng'), roadJsonStore.getAt(b).get('customerStoreHouseLat')),17);
			}
		});
	}
	else
	{
		maps.getBestMap(pointsOffice.concat(pointsHouse));
		grid.on('rowmousedown',function(a,b,c){
			if(roadJsonStore.getAt(b))
			{
				maps.moveToCenter(new LTPoint(roadJsonStore.getAt(b).get('customerOfficeAdressLng'), roadJsonStore.getAt(b).get('customerOfficeAdressLat')),17);
			}
		});
	}
	
	//地图模块加载结束
	//设置鼠标单击事件
	//grid.on('rowmousedown',function(a,b,c){
//		maps.moveToCenter(new LTPoint( ds.getAt(b).get('lag'), ds.getAt(b).get('lat')),17)
//	});
//	//设置鼠标单击事件结束
//	//设置详细列表鼠标浮动事件
//	grid.on('mouseover',function(e){//添加mouseover事件
//		var rowIndex = grid.getStore().getCount();//grid的行数
//		for(var j=0;j<rowIndex;j++)
//		{
//			grid.getView().getRow(j).style.backgroundColor='#ffffff';
//		}
//		var index = grid.getView().findRowIndex(e.getTarget());//根据mouse所在的target可以取到列的位置
//		for(var j=0;j<rowIndex;j++)
//		{
//			if(index==j)
//			{
//				break;
//			}
//			grid.getView().getRow(j).style.backgroundColor='#ffffff';
//		}
//	});
}

//鼠标浮动及单击事件方法
function getClickCallBackCustomer(marker,html,name,i)
{
	return function(){
		var infoWin=marker.openInfoWinHtml(html); infoWin.setTitle(name);
		//marker.getObject().style.zIndex=520;
		//grid.getView().getRow(i).style.backgroundColor='#DCDCDC'; 
	}
}

function addAllWangDianMarker(pointsAddress,idsWandDian,idsWandDian,wangdianName,wangdianAddress,provinceWangDian,saleAreaId,wangdianAreaOwen,wangdianfuzeren,wdfzrTel,wangdianyewuren,wdywrTel,saleId,wangdianPhoto,wangdianOwen,beizhu)
{
	for(var i=0;i<idsWandDian.length;i++)
	{
		//alert(pointsAddress[i].getLongitude()+"||"+pointsAddress[i].getLatitude());
		//alert(customerName[i]);
		var html="网点名称："+wangdianName[i]+"<br>";
		html+="所在城市："+provinceWangDian[i]+"<br>";
		html+="网点地址："+wangdianAddress[i]+"<br>";
		
		html+="网点所属片区："+wangdianAreaOwen[i]+"<br>";
		html+="网点所属客户："+wangdianOwen[i]+"<br>";
		
		html+="网点负责人："+wangdianfuzeren[i]+"<br>";
		html+="网点负责人电话："+wdfzrTel[i]+"<br>";
		
		html+="网点业务人员："+wangdianyewuren[i]+"<br>";
		html+="网点业务人员电话："+wdywrTel[i]+"<br>";
		
		html+="备注信息："+beizhu[i]+"<br>";
		
		html+="<img src='"+wangdianPhoto[i]+"' onerror='this.src=\"images/noimg.jpg\"' target='_blank' onmouseover='imgZoomIn(this)' onmouseout='imgZoomOut(this)' style='width:210px;height:160px;'/>";
		
		var iconUrl="icons/kehu.png";
		var icon2=new LTIcon(iconUrl,[30,30],[15,30]);//创建一个图标
		var marker = new LTMarker(pointsAddress[i],icon2);
		maps.addOverLay(marker);
		html="<div style='text-align:left'>"+html+"</div>"
		LTEvent.addListener(marker,"click",getClickCallBackWangDian(marker,html,wangdianName[i],i));
	}
	maps.getBestMap(pointsAddress);
	grid.on('rowmousedown',function(a,b,c){
		if(wangDianJsonStore.getAt(b))
		{
			
			for(var i=0;i<markerChange.length;i++)
			{
				maps.removeOverLay(markerChange[i]);
			}
			
			var html="网点名称："+wangdianName[b]+"<br>";
			html+="所在城市："+provinceWangDian[b]+"<br>";
			html+="网点地址："+wangdianAddress[b]+"<br>";
			
			html+="网点所属片区："+wangdianAreaOwen[b]+"<br>";
			html+="网点所属客户："+wangdianOwen[b]+"<br>";
			
			html+="网点负责人："+wangdianfuzeren[b]+"<br>";
			html+="网点负责人电话："+wdfzrTel[b]+"<br>";
			
			html+="网点业务人员："+wangdianyewuren[b]+"<br>";
			html+="网点业务人员电话："+wdywrTel[b]+"<br>";
			
			html+="备注信息："+beizhu[b]+"<br>";
			
			html+="<img src='"+wangdianPhoto[b]+"' onerror='this.src=\"images/noimg.jpg\"' target='_blank' onmouseover='imgZoomIn(this)' onmouseout='imgZoomOut(this)' style='width:210px;height:160px;'/>";
			
			var iconUrl="icons/kehu2.png";
			var icon2=new LTIcon(iconUrl,[30,30],[15,30]);//创建一个图标
			var marker = new LTMarker(pointsAddress[b],icon2);
			maps.addOverLay(marker);
			html="<div style='text-align:left'>"+html+"</div>"
			LTEvent.addListener(marker,"click",getClickCallBackWangDian(marker,html,wangdianName[b],b));
			markerChange.push(marker);
			marker.getObject().style.zIndex=520;
			
			maps.moveToCenter(new LTPoint(wangDianJsonStore.getAt(b).get('wangdianAddressLng'), wangDianJsonStore.getAt(b).get('wangdianAddressLat')),17);
		}
	});
}

//鼠标浮动及单击事件方法
function getClickCallBackWangDian(marker,html,name,i)
{
	return function(){
		var infoWin=marker.openInfoWinHtml(html); infoWin.setTitle(name);
		//marker.getObject().style.zIndex=520;
		//grid.getView().getRow(i).style.backgroundColor='#DCDCDC';
	}
}

function indexOfStr(val,text){
	for(var i = 0; i < val.length; i++)
	{
		if(val[i] == text)return i;
	}
	return -1;
}

function removeStr(val,text){
	var index = indexOfStr(val,text);
	if (index > -1) {
		val.splice(index, 1);
	}
}

function clearCustomerArray()
{
	pointsOffice.splice(0,pointsOffice.length);
	pointsHouse.splice(0,pointsHouse.length);
	ids.splice(0,ids.length);
	customerName.splice(0,customerName.length);
	customerOfficeAdress.splice(0,customerOfficeAdress.length);
	customerStoreHouse.splice(0,customerStoreHouse.length);
	province.splice(0,province.length);
	kehuxiaqu.splice(0,kehuxiaqu.length);
	kehufuzeren.splice(0,kehufuzeren.length);
	kehufuzerenTel.splice(0,kehufuzerenTel.length);
	beizhu.splice(0,beizhu.length);
}

function clearWangDianArray()
{
	pointsAddress.splice(0,pointsAddress.length);
	idsWandDian.splice(0,idsWandDian.length);
	wangdianName.splice(0,wangdianName.length);
	wangdianAddress.splice(0,wangdianAddress.length);
	provinceWangDian.splice(0,provinceWangDian.length);
	saleAreaId.splice(0,saleAreaId.length);
	wangdianAreaOwen.splice(0,wangdianAreaOwen.length);
	wangdianfuzeren.splice(0,wangdianfuzeren.length);
	wdfzrTel.splice(0,wdfzrTel.length);
	kehufuzerenTel.splice(0,kehufuzerenTel.length);
	wdywrTel.splice(0,wdywrTel.length);
	saleId.splice(0,saleId.length);
	wangdianPhoto.splice(0,wangdianPhoto.length);
	wangdianOwen.splice(0,wangdianOwen.length);
	beizhu.splice(0,beizhu.length);
}

function clearCaiJiArray()
{
	caiJiPoints.splice(0,caiJiPoints.length);
	caiJiIDS.splice(0,caiJiIDS.length);
	caiJiWangDianName.splice(0,caiJiWangDianName.length);
	caiJiWangDianNumber.splice(0,caiJiWangDianNumber.length);
	caiJiLandmarksName.splice(0,caiJiLandmarksName.length);
	caiJiPositionAddress.splice(0,caiJiPositionAddress.length);
	caiJiWangdianPhone.splice(0,caiJiWangdianPhone.length);
}

var imgDefaultWidth = 210;
var imgDefaultHeight = 160;
var imgDefaultWidthZoomIn = 250;
var imgDefaultHeightZoomOut = 200;
function imgZoomIn(self)
{
	self.style.width=imgDefaultWidthZoomIn;
	self.style.height=imgDefaultHeightZoomOut;
	self.style.position="relative";
	self.style.left = (-(imgDefaultWidthZoomIn-imgDefaultWidth)/2)+"px";
	self.style.top = (-(imgDefaultHeightZoomOut-imgDefaultHeight)/2)+"px";
	self.style.zIndex = 1;
}

function imgZoomOut(self)
{
	self.style.width=imgDefaultWidth;
	self.style.height=imgDefaultHeight;
	self.style.left = "0px";
	self.style.top = "0px";
}

function loginOut()
{
	Ext.Ajax.request({
		url:'loginout.asp',
		method:'get',
		params:{
			uid:'uid'
		},
		success:function(req){
			//alert(req.responseText);
			//window.close();
			location.href="login.asp";
			/*if(req.responseText=='ok')
			{
				Ext.Msg.alert('success','You got it!');
			}
			else
			{
				Ext.Msg.alert('sorry','You lost!');
			}*/
		}
	});
}

function loginAdmin()
{
	location.href="admin.asp";
}

function obj2str(o){
	var r = [];
	if(typeof o =="string") return "\""+o.replace(/([\'\"\\])/g,"\\$1").replace(/(\n)/g,"\\n").replace(/(\r)/g,"\\r").replace(/(\t)/g,"\\t")+"\"";
	if(typeof o =="undefined") return "";
	if(typeof o == "object"){
		if(o===null) return "null";
		else if(!o.sort){
			for(var i in o)
				r.push(i+":"+obj2str(o[i]))
			r="{"+r.join()+"}"
		}else{
			for(var i =0;i<o.length;i++)
				r.push(obj2str(o[i]))
			r="["+r.join()+"]"
		}
		return r;
	}
	return o.toString();
}

function userTypeTF(value,key)
{
	var un = value.indexOf(",");
	var flag = false;
	if(un == 1)
	{
		var arr = value.split(",");
		for(var i=0;i<arr.length;i++)
		{
			if(arr[i] == key)
			{
				return true;
			}
		}
	}
	else if(value==key)
	{
		return true;
	}
}

</script>
<style type="text/css">
<!--
.style1 {
	font-size: 14px;
	font-weight: bold;
}
-->
body{
text-align:left;
}
        </style>
</head>
<body>
<!--<div id="north-div">
  <div class="style1" id="menu">网点查询系统</div>
</div>-->
<div id="north-div" style="background-image:url(images/bg_head.jpg)"><img src="images/logoTop.jpg">
  <div class="style1" style="display:none" id="menu">网点查询系统</div>
  <div style="cursor:pointer" onClick="loginOut();">
  	<div style="position:absolute; right:80; top:15;font-size:12px; background-image:url(images/exit.jpg); width:20px; height:18px"></div><div style="position:absolute; right:30; top:15;font-size:12px">退出系统</div>
  </div>
  <div style="cursor:pointer" onClick="loginAdmin();">
  	<div style="position:absolute; right:200; top:15;font-size:12px; background-image:url(images/admin.jpg); width:20px; height:20px"></div>
	<div style="position:absolute; right:125; top:15;font-size:12px">登录管理页面</div>
  </div>
</div>
<div id="treeCitysSearch"></div>
<div id="treeSaleAreaSearchDiv"></div>
<div id="myMap" style="position:relative; width:100%; height:100%;border:black solid 0px;"></div>
<div id="south-div" style="font-size:12px;"><%=CC_CopyRight%></div>
<div id="tree-panel"></div>
</body>
</html>
